// 导入定义验证规则的模块
const joi = require('joi')

// 定义 标题、分类、内容、发布状态 的验证规则
const title = joi.string().required()
const sort = joi.string().required()
const context = joi.string().required().allow('')
const cover_img = joi.string().required()
const summary = joi.string().required()
const time = joi.string().required()
const nowtime = joi.string().required()
const last = joi.string().required()
const id = joi.number().required()
const keyWord = joi.string().required()

// 验证规则对象 - 发布/修改文章
exports.add_article_schema = {
  body: {
    title,
    sort,
    context,
    cover_img,
    summary,
    time,
    nowtime,
    last
  },
}
// 验证规则对象 - 修改文章
exports.update_article_schema = {
  body: {
    title,
    sort,
    context,
    cover_img,
    summary,
    time,
    nowtime,
    last,
    id
  },
}
// 验证规则对象 - 保存文章
exports.save_article_schema = {
  body: {
    title,
    sort,
    context,
    cover_img,
    summary,
  }
}
// 验证规则对象 -  删除文章
exports.delete_article_schema = {
  body:{
    id
  }
}
// 验证规则对象 - 展示一篇
exports.show_article_schema = {
  body:{
    id
  }
}
// 验证规则对象 - 搜索分类
exports.searchSort_article_schema={
  body:{
    sort
  }
}
// 验证规则对象 - 关键字搜索
exports.keySearch_article_schema={
  body:{
    keyWord
  }
}

